<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
</head>
<body>
<input type="file" id="f1">
<input type="button" value="ajax请求" id="btn1">;
<script>
window.onload=function () {
	let oBtn = document.getElementById('btn1');
	let oF1 = document.getElementById('f1');

	oBtn.onclick=function () {
	  let formData = new FormData();
		  // formData.set('a',12);
		  formData.set('ccc',oF1);

	  let xhr = new XMLHttpRequest();
	  xhr.open('POST','1.php',true);
	  xhr.send(formData);
	  xhr.onreadystatechange=function () {
	    if(xhr.readyState==4){
	    	if(xhr.status>=200&&xhr.status<300||xhr.status==304){
	    		alert("成功"+xhr.responseText);
		    };
	    }
	  }
	}
}
</script>
</body>
</html>